package thread;

public class Tinckt {
    public static void main(String[] args) {
        Buy buy =new Buy();
        while(true){
            new Thread(buy,"student").start();
            new Thread(buy,"teach").start();
            new Thread(buy,"黄牛").start();
        }

    }

}
class Buy implements Runnable{
    int tinct=10;
    @Override
    public synchronized void run() {

            if (tinct<=0){
                return;
            }
            try {
                Thread.sleep(100);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }

            System.out.println(Thread.currentThread().getName()+"买了第"+tinct+"张票");
            tinct--;
        }


}
